<template>
  <div class="container">
    <div class="opt-area-02">
      <div class="right-con">
        <div class="input-frame" style="width: 164px">
          <Input type="text" @on-click="selectlist(1)" placeholder="请输入姓名" style="width: 164px" v-model="params.name" icon="ios-search"/>
        </div>
        <div class="input-frame" style="width: 164px">
          <Input type="text" @on-click="selectlist(1)" placeholder="请输入电话号码" style="width: 164px" v-model="params.mobile" icon="ios-search"/>
        </div>
        <div class="input-frame" style="width: 164px">
          <Input type="text" @on-click="selectlist(1)" placeholder="订单编号" style="width: 164px" v-model="params.code" icon="ios-search"/>
        </div>
        <div class="input-frame" style="width: 164px">
          <Input type="text" @on-click="selectlist(1)" placeholder="事项id" style="width: 164px" v-model="params.item_id" icon="ios-search"/>
        </div>
        <Button type="info" size="small" @click="selectlist(1)" style="margin-top: 5px;margin-right:5px">搜索</Button>
        <Button type="info" size="small" @click="getExportDataList()" style="margin-top: 5px;margin-right:5px">刷新</Button>
      </div>
    </div>
    <Table :loading="countData.loading" border :columns="columns1" :data="dataList" size="small" ref="table">
      <template slot-scope="{ row }" slot="file_url">
        <Tooltip transfer max-width="300" :content="row.paramstitle" placement="right" style="margin-left:30%;width: max-content;">
          <i class='iconfont icon-tupian' style="font-size:30px;color:orange;margin-right:50px;cursor: pointer;" v-if="(row.url).indexOf('.jpg') != -1" @click="openFile(row.url)"></i>
          <i class='iconfont icon-tupian' style="font-size:30px;color:orange;margin-right:50px;cursor: pointer;" v-if="(row.url).indexOf('.png') != -1" @click="openFile(row.url)"></i>
          <i class='iconfont icon-tupian' style="font-size:30px;color:orange;margin-right:50px;cursor: pointer;" v-if="(row.url).indexOf('.jpeg') != -1" @click="openFile(row.url)"></i>
        </Tooltip>
      </template>
    </Table>
    <Row type="flex" justify="end" class="page_style">
      <Page :current="params.pageNo" :total="params.totalRecord" show-sizer :page-size="params.pageSize" show-total @on-change="pageAction" @on-page-size-change="pageSizeChange"/>
    </Row>
    <template>
      <Row v-if="loadData == true">
        <Col class="demo-spin-col" span="8" offset="8">
          <Spin fix>
            <Icon type="ios-loading" size=18 class="demo-spin-icon-load"></Icon>
            <div>查询中...</div>
          </Spin>
        </Col>
      </Row>
    </template>
  </div>
</template>

<script>

import { findParamsImgList } from '@/api/mainv3'

export default {
  name: 'index',
  data () {
    return {
      modal1: false,
      disabledShow: false,
      params: { name: '', mobile: '', item_id: '', code: '', pageNo: 1, pageSize: 10, totalRecord: 0 },
      formData: {},
      countData: { loading: false, fcnum: 0, ytbnum: 0, zcnum: 0 },
      columns1: [
        { title: '事项编号', key: 'code', align: 'center' },
        { title: '姓名', key: 'name', align: 'center' },
        { title: '联系电话', key: 'mobile', align: 'center' },
        { title: '事项名称', key: 'title', align: 'center' },
        { title: '创建时间', key: 'create_time', align: 'center' },
        { title: '附件', slot: 'file_url', width: 200, align: 'center' }
      ],
      loadData: false,
      dataList: []
    }
  },
  methods: {
    openFile (url) {
      window.open(url)
    },
    selectlist (inpageNo) {
      this.loadData = true
      if (inpageNo) {
        this.params.pageNo = inpageNo
      } else {
        this.params.pageNo = 1
      }
      findParamsImgList(this.params).then(ret => {
        let result = ret.data
        if (ret.data.errcode === 0) {
          this.dataList = ret.data.data.results
          this.countData.fcnum = ret.data.data.totalRecord
          this.loadData = false
          this.params = {
            pageNo: result.data.pageNo,
            pageSize: result.data.pageSize,
            totalPage: result.data.totalPage,
            totalRecord: result.data.totalRecord,
            name: this.params.name,
            mobile: this.params.mobile,
            code: this.params.code,
            item_id: this.params.item_id
          }
        } else {
          this.loadData = true
          this.$Notice.error({
            title: '查询列表信息失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    getExportDataList () {
      this.selectlist()
    },
    pageAction (page) {
      this.params.pageNo = page
      this.selectlist()
    },
    pageSizeChange (e) {
      this.params.pageSize = e
      this.selectlist(this.params.pageNo)
    }
  },
  mounted () {
    this.selectlist()
  }
}
</script>

<style scoped>
.page_style {
  margin: 20px 5px;
}
.input-frame {
  width: 120px;
  margin-right: 10px;
}
.house-list > .group {
  background: white;
  padding: 10px;
  margin-top: 10px;
}
.house-list > .group > .item {
  border-bottom: 1px solid #f5f5f5;
  padding: 10px 0;
}
.house-list > .group > .item .top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}
.house-list > .group > .item .title {
  font-size: 14px;
  color: #333333;
}
.house-list > .group > .item .address {
  font-size: 12px;
  color: gray;
  display: flex;
  align-items: center;
}
.house-list > .group > .item .detail {
  font-size: 12px;
  color: dodgerblue;
}
.opt-area-02 {
  display: flex;
  align-items: center;
  flex-direction: column;
  border: 1px solid #abdcff;
  background-color: #f0faff;
  padding: 8px 16px 8px 16px;
  border-radius: 4px;
  margin-bottom: 10px;
}
.opt-area-02 .right-con {
  width: 100%;
  margin-top: 5px;
  display: flex;
}
.opt-area-02 .left-con {
  font-size: 14px;
  width: 100%;
}
.opt-area-02 .left-con span {
  font-weight: bold;
}
.opt-area-02 .right-con input {
  width: 150px;
  margin-right: 10px;
}

.opt-area-02 .right-con .input-frame {
  width: 200px;
  margin-right: 10px;
}
.table-action-btn {
  margin-right: 3px;
}
.container >>> .ivu-btn-small {
  height: 24px;
  padding: 0 5px;
  font-size: 12px;
  border-radius: 3px;
}
.btn-action {
  margin-bottom: 10px;
}
.mp10 {
  margin-right: 10px;
}
.title-style {
  color: red;
}
.mb20 {
  margin-bottom: 20px;
}
.mt20 {
  margin-top: 20px;
}
.ivu-table-row {
  height: 57px;
}
.ivu-form-item{
  /*margin-bottom: 0%;*/
}
</style>
